<!-- 预约等级列表页 -->
<template>
  <el-dialog
    v-if="dialogVisible"
    v-model="dialogVisible"
    :title="title"
    width="80%"
    draggable
  >
    <FormDesign
      ref="formDataArea"
      :current-route-path="currentRoutePath"
      :formData="formData"
    />
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleSave"> 保存 </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import FormDesign from "./FormDesign.vue";
export default {
  props: {
    currentRoutePath: {
      type: String,
      default: "",
    },
    loadData: {
      type: Function,
      default: null,
    },
  },
  components: { FormDesign },
  data() {
    return {
      formData: {},
      dialogVisible: false,
      title: "",
    };
  },
  methods: {
    show(formData) {
      this.formData = formData;
      this.dialogVisible = true;
    },
    async handleSave() {
      let res = await this.$refs.formDataArea.handleSend();
      if (res.success) {
        this.$notify.success({
          title: "提示",
          message: "保存成功",
          showClose: false,
        });
        this.dialogVisible = false;
        if (this.loadData) {
          this.loadData();
        }
      } else {
        this.$notify.error({
          title: "提示",
          message: "获取表单数据失败",
          showClose: false,
        });
      }
    },
  },
};
</script>
